<?php
namespace Home\Controller;
use Think\Controller;
use Org\Net;
class EmailController extends Controller {
    /**
     * 获取目录的结构
     * @author 李俊
     * @param  [string] $path [目录路径]
     * @return [array]       [目录结构数组]
     */
    public function dirtree($path) {
        $handle = opendir($path);
        $itemArray=array();
        while (false !== ($file = readdir($handle))) {
            if (($file=='.')||($file=='..')){
            }
            else if($file==null || $file=='NULL' || $file==''){

            }
            elseif (is_dir($path.$file)) {
                //array_push($itemArray, array('files'=> $file));
            }else{
                array_push($itemArray, array('files'=>$file));
            }
        }
        return $itemArray;
    }
    public function email(){
        $emailfiles=self::dirtree(C('EMAIL_PATH'));
        $this->assign('emailfiles',$emailfiles);

        $this->assign('title','邮件下载');
        $this->assign('currentname','email');
        $this->display();
    }
    public function getemail(){
        $emailfiles=self::dirtree(C('EMAIL_PATH'));
        var_dump($emailfiles[0]);
        $this->ajaxReturn(array('data'=>$emailfiles),'json');
    }
    public function downloademail(){
        if(IS_GET){
            //emailfile
            $Http=new Net\Http();
            $Http::download(C('EMAIL_PATH').I('get.emailfile'),I('get.emailfile'));
        }
    }
}